<template>
	<view class="fixtop">
		<fixtitletopVue>
			<template #l>
				<view class="fix-l" @click="back">
					<view>
						<view class="iconfont icon-jiantou"></view>
					</view>
				</view>
			</template>
			<template #c>
				<view class="fix-c">
					{{title}}
				</view>
			</template>
		</fixtitletopVue>
	</view>
    <scroll-view scroll-y @scrolltolower="changepgae">
		<view class="" v-for="i in currlxdata" :key="i.id" @click="goprsoxq(i)">
			<productCardVue :data="i"/>
		</view>
		<uni-load-more :status="crdata.length<6?'no-more':'loading'"></uni-load-more>
    </scroll-view>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		ref
	} from 'vue'
	import {
		getstatusheight,
		gettitleheight
	} from '@/util/getsysinfo.js'
	import fixtitletopVue from '../../components/fixtitletop/fixtitletop.vue';
	import productCardVue from '../../components/product-card/product-card.vue';
	import {sslxproduc} from '@/api/index.js'
	import addressstore from '@/store/address.js'
	const useaddressstore=addressstore()
		const heighttop = gettitleheight() + getstatusheight() + 'px'
	const title = ref()
	const lx = ref()
	const offset=ref(1)
	const limit=ref(6)
	const currlxdata=ref([])
	const crdata=ref([])
	onLoad(e => {
		title.value = e.title
		lx.value = e.lx
		getlxdata()
	})
	const goprsoxq=e=>{
		uni.navigateTo({
			url:`/pages/producet-xq/producet-xq?userid=${e.shoperid}&id=${e.id}`
		})
	}
	const changepgae=()=>{
		if(crdata.length<6)return
		offset.value++
		getlxdata()
	}
	const getlxdata=async()=>{
		const rudata=await sslxproduc(useaddressstore.address,limit.value,offset.value,lx.value)
		if(rudata.code==200){
			crdata.value=rudata.data
			currlxdata.value=[...currlxdata.value,...rudata.data]
		}else{
			uni.showToast({
				title:"该地区暂无数据",
				icon:"none"
			})
		}
	}
	const back = () => {
		uni.navigateBack()
	}
</script>

<style lang="scss" scoped>
	scroll-view{
		height: calc(100vh - v-bind(heighttop));
		padding: 20rpx;
	}
	.fixtop {
		background-color: #eee;
		padding: 0 20rpx;
		border-bottom: 1rpx solid #dcdcdc;

		.fix-l {
			height: 100%;
			width: 100%;
			display: flex;
			align-items: center;

			.iconfont {
				font-size: 25rpx;
			}
		}

		.fix-c {
			height: 100%;
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 30rpx;
		}
	}
</style>